/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/

package com.nurdrobotics;

import edu.wpi.first.wpilibj.DriverStation;

/**
 * 
 */
public class DSControls {
    // The following variables give names to each of the analog slider
    // channels on the DriverStation
    public static final int SLIDER_AUTONOMOUS_MAX_TIME = 1;
    public static final int SLIDER_AUTONOMOUS_MAX_SPEED = 2;
    public static final int SLIDER_LIFTER_TIMER_PERCENT = 3;
    public static final int SLIDER_STAGER_TIMER_PERCENT = 4;

    // The following variables give names to each of the digital switches
    // on the DriverStation
    public static final int BUTTON_DRIVETRAIN_ENABLE = 1;
    public static final int BUTTON_LIFTER_ENABLE = 2;
    public static final int BUTTON_SHOOTER_ENABLE = 3;
    public static final int BUTTON_WEDGE_ENABLE = 4;

    private static DriverStation m_ds = null;

    /*
     * Return the value of the specified analog slider on the DriverStation
     * The value will be returned in the range of 0 to 1
     */
    public static double getSlider(int channel) {
        if(m_ds == null) {
            m_ds = DriverStation.getInstance();
            if(m_ds == null) {
                System.out.println("DSControls.getSlider: DriverStation not found");
                return 0;
            }
        }
        
        // Analog inputs reads 0 to 3.3
        // By dividing the returned value by 3.3 we get values in the
        // range of 0 to 1 inclusive
        return(m_ds.getAnalogIn(channel) / 3.3);
    }
}
